#ifndef __BUOLA_SCENE_CCAMERA_H__
#define __BUOLA_SCENE_CCAMERA_H__

#include <buola/scene.h>
#include <buola/mat.h>
#include <buola/mat/transformations.h>

namespace buola { namespace scene {

class CCamera : public UShared
{
public:
    CCamera();
    virtual ~CCamera();

public:
    void SetAspect(double pAspect);
    double GetAspect()  {   return mAspect; }
    
    void LookAt(const mat::CVec3d &pAt,const mat::CVec3d &pFrom=mat::CVec3d(0,0,0),const mat::CVec3d &pUp=mat::CVec3d(0,0,1));
    void LookAt(const mat::CVec3d &pAt,const mat::C3DRotation &pRotation,double pDist);
    void LookFrom(const mat::CVec3d &pFrom,const mat::CQuat_d &pRotation);

    const mat::CMat4d &GetProjectionMatrix()
    {
        if(!mProjectionValid) CalcProjection();
        return mProjection;
    }

    mat::CMat34d GetLookAtMatrix();

    const mat::CVec3d& GetAt() const { return mAt; }
    const mat::CVec3d& GetFrom() const { return mFrom; }
    const mat::CVec3d& GetUp() const { return mUp; }

    void AttachTo(PTransform pTransform);
    
private:
    virtual void CalcProjection()=0;
    
protected:
    bool mProjectionValid;
    mat::CMat4d mProjection;

    mat::CVec3d mAt,mFrom,mUp;

    double mAspect;
    
    PTransform mTransform;
};

/*namespace scene*/ } /*namespace buola*/ }

#endif
